import java.util.*;

public class demo2 {
    public int findMinimum(int n, int[] left, int[] right) {
        // write code here
        int count = 0;
        int left_sum = 0;
        int right_sum = 0;
        for (int i = 0; i < n; i++) {
            if (right[i] == 0 || left[i] == 0) {
                count = count + left[i] + right[i];
                left[i] = 0;
                right[i] = 0;
            }
        }
        for (int i = 0; i < n; i++) {
            left_sum += left[i];
            right_sum += right[i];
        }
        if (left_sum > right_sum) {
            count += 1;
            Arrays.sort(right);
            for (int i = n - 1; i > 0; i--) {
                if (right[i - 1] != 0) {
                    count += right[i];
                }
            }
            count += 1;
        } else {
            count += 1;
            Arrays.sort(left);
            for (int i = n - 1; i > 0; i--) {
                if (left[i - 1] != 0) {
                    count += left[i];
                }
            }
            count += 1;
        }
        return count;
    }
}